<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFinanceSuppliersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('finance_suppliers', function (Blueprint $table) {
            $table->id();
            $table->char('plat_cust_no', 32)->default('')->index()->comment('客户编号');
            $table->char('name', 16)->comment('名称');
            $table->char('gender', 1)->default('M')->comment('性别(跟银行接口一样); M:男 F:女');
            $table->date('birthday')->nullable()->comment('出生日期');
            $table->char('id_type', 1)->default('A')->comment('证件类型(跟银行接口一样); A:身份证 E:港澳居民往来大陆通行证 F:台湾居民往来大陆通行证');
            $table->char('id_no', 32)->default('')->comment('证件号');
            $table->char('phone', 16)->default('')->comment('预留手机号');
            $table->char('email')->default('')->comment('email');
            $table->char('bank', 16)->default('')->comment('银行(国际银行文档编号)');
            $table->char('bank_card_no', 32)->default('')->comment('银行卡号');
            $table->date('legal_expire_date')->nullable()->comment('证件有效期');
            $table->date('legal_auth_date')->nullable()->comment('证件起始日期');
            $table->char('occupation', 8)->nullable()->comment('职业');
            $table->char('address')->default('')->comment('联系地址');
            $table->char('legal_address')->default('')->comment('证件地址');
            $table->char('issue_office')->default('')->comment('发证机关');
            $table->text('ret_url')->nullable()->comment('银行方注册页面地址(base64 存放)');
            $table->char('trans_id', 32)->index()->comment('发起注册时的 transId,用于回调时查询');
            $table->char('acct_no', 32)->default('')->comment('预付款账号');
            $table->tinyInteger('check_stat')->default(0)->comment('审核结果; 0:注册中(银行端没有这个值,这里作为缺省值) 1:通过 2:失败(客户信息错误) 3:失败(证件文件错误)');
            $table->text('remark')->nullable()->comment('审核备注');
            $table->json('register_callback_snapshot')->nullable()->comment('注册回调通知快照');

            $table->tinyInteger('status')->default(3)->comment('状态; 1:正常 2:禁用 3:注册中');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('finance_suppliers');
    }
}
